void main() {
  var names = <String>["张三", "李四"];
  var numbers = <int>[1, 2, 3];
  fx();
  List<String> s = ["1", "2"];
  first<String>(s);
}


// 运行时中的泛型集合
void fx() {
  var names = List<String>();
  names.addAll(['Seth', 'Kathy', 'Lars']);
  print(names is List<String>); // true
}

// 限制泛型类型
void fx2() {
  var h = Hunter<Person>();
  var zs = Hunter<ZhangSan>();
}

// 使用泛型函数
T first<T>(List<T> ts) {
  // Do some initial work or error checking, then...
  T tmp = ts[0];
  // Do some additional checking or processing...
  return tmp;
}

class Person {

}

class ZhangSan extends Person {

}

class Hunter<T extends Person> {
  // Implementation goes here...
  String toString() => "Instance of 'Foo<$T>'";
}